<?php
namespace Hive;
/**
 * Master Customizing Object.
 * 
 * This instanct is use to handle the customizing at the applicaition level
 * 
 * @package Hive
 * @author Xavier VILAIN
 * @license #license#
 */
class Customizing {
	
	/**
	 * Admin Master Authorization
	 */
	const AUTH_ADMIN = 'hive-admin';
		
	/**
	 * Admin User Management
	 */
	const AUTH_ADMIN_USERS_W = 'hive-admin-users-w';
	
	/**
	 * Admin See User Information
	 */
	const AUTH_ADMIN_USERS_R = 'hive-admin-users-r';
	
	/**
	 * Singleton instance
	 *
	 * @var \Fox\Html\Steppers
	 */
	private static $_instance;

	/**
	 * Retrieve singleton instance
	 *
	 * @return Customizing
	 */
	public static function instance()
	{
		if (null === self::$_instance) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}
	
	/**
	 * 
	 * Is the application in a demonstration mode ?
	 * @return bool
	 * 
	 */
	public function isDemo() {
		if(defined('DEMO_MODE')) {
			return DEMO_MODE;
		} else {
			return false;
		}
	}
	
	/**
	 * Display Demonstration Error Message
	 * @return void
	 */
	public function demonstrationErrorMessage() {
		$link = '?mod=account&act=subscribe';
		\Fox\Message::Error(\Msg(\Hive::BUNDLE,\Hive::DEMONSTRATION_ERROR_MESSAGE,$link));
	}
	
	/**
	 * If the system has group functionnality enable
	 * @return bool
	 */
	public function hasGroup() {
		if(defined('HIVE_GROUPING')) {
			return HIVE_GROUPING;
		} else {
			return true;
		}
	}
	
	/**
	 * Load default currency object from the customizing
	 * 
	 * @return \Hive\Currency
	 */
	public function defaultCurrency() {
		// Load default Currency from customizing
		//@TODO
		$code = 'EUR';
		try {
			return \Fox\Dao::load(\Hive\Currency::className(),$code.':'.\Xview::instance()->language());
		} catch(Fox\Object\Exception\NotExist $e) {
			return new \Hive\Currency();
		}
	}
	
	/**
	 * Application Name
	 */
	public function applicationName() {
		$appname = \Xview::instance()->application()->wname;
		// @TODO add a customizing capability
		return $appname;
	}
}